package com.atguigu.spzx.product.service.impl;

import com.atguigu.spzx.model.entity.order.OrderItem;
import com.atguigu.spzx.product.mapper.ProductSkuMapper;
import com.atguigu.spzx.product.service.ProductSkuService;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

@Service
public class ProductSkuServiceImpl implements ProductSkuService {
    @Resource
    ProductSkuMapper productSkuMapper;
    @CacheEvict(value = "product:item" , key = "#orderItem.skuId")
    public void updateSkuStockAndSales(OrderItem orderItem) {
        productSkuMapper.updateSalesAndStockById(orderItem.getSkuId() , orderItem.getSkuNum());
    }
}
